package com.lxd.controller;

import java.util.List;

import com.lxd.entity.query.ActivityQuery;
import com.lxd.entity.po.Activity;
import com.lxd.entity.vo.ActivityVO;
import com.lxd.entity.vo.ResponseVO;
import com.lxd.service.ActivityService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 *  Controller
 */
@RestController("activityController")
@RequestMapping("/activity")
public class ActivityController extends ABaseController{

	@Resource
	private ActivityService activityService;
	/**
	 * 根据条件分页查询
	 */
	@RequestMapping("/loadDataList")
	public ResponseVO loadDataList(ActivityQuery query){
		return getSuccessResponseVO(activityService.findListByPage(query));
	}



	/**
	 * 新增
	 */
	@RequestMapping("/add")
	public ResponseVO add(@RequestBody Activity bean) {
		activityService.add(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增
	 */
	@RequestMapping("/addBatch")
	public ResponseVO addBatch(@RequestBody List<Activity> listBean) {
		activityService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增/修改
	 */
	@RequestMapping("/addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<Activity> listBean) {
		activityService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id查询对象
	 */
	@RequestMapping("/getActivityById")
	public ResponseVO getActivityById(Long id) {
		return getSuccessResponseVO(activityService.getActivityById(id));
	}

	/**
	 * 根据Id修改对象
	 */
	@RequestMapping("/updateActivityById")
	public ResponseVO updateActivityById(@RequestBody Activity bean) {
		activityService.updateActivityById(bean,bean.getId());
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id删除
	 */
	@RequestMapping("/deleteActivityById")
	public ResponseVO deleteActivityById(@RequestBody ActivityVO activityVO) {
		activityService.deleteActivityById(activityVO.getId());
		return getSuccessResponseVO(null);
	}
	@RequestMapping("/totalCount")
	public ResponseVO totalCount() {
		Integer count = activityService.getTotalCount();
		return getSuccessResponseVO(count);
	}
}